package com.hy.main.demo.rabbitmq;

import com.rabbitmq.client.Channel;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @Author yang DongYong
 * @Date 2022/5/11 - 05 - 11 - 1:49
 * @Description: com.hy.main.demo.rabbitmq
 * @version: 1.0
 * 消息发布者
 */
public class EmitLog {
    public static final String EXCHANGE_NAME = "logs";
    public static final String EXCHANGE_NAME02 = "direct_logs";
    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMqUtils.getChannel();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            // 发送信息
            channel.basicPublish(EXCHANGE_NAME02,"Error",null,scanner.next().getBytes(StandardCharsets.UTF_8));
            System.out.println("生产者消息发布成功");
        }
    }
}
